package cn.bdqn.exception;

import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(UnauthorizedException.class)
    public ModelAndView unauthorizedException(HttpServletRequest request,
                                              UnauthorizedException unauthorizedException){
        ModelAndView mv=new ModelAndView("403");
        mv.addObject("exception",unauthorizedException);
        mv.addObject("url",request.getRequestURL());
        return mv;
    }
}
